Imports pixolut.BizBlox
Imports NUnit.Framework

<TestFixture()> Public Class TOTests
    Public Sub New()
        MyBase.New()
    End Sub

    <TestFixtureSetUp()> Public Sub GlobalInit()
        'do nothing...
    End Sub

    <TestFixtureTearDown()> Public Sub GlobalDestruct()
        'do nothing...
    End Sub

    <SetUp()> Public Sub LocalInit()
        'do nothing...
    End Sub

    <TearDown()> Public Sub LocalDestruct()
        Setup.ClearDataSet()
    End Sub

    <Test()> Public Sub testTOget()
        Dim sObj As Student = Setup.CreateTestStudent()
        Dim fObj As Food = Setup.CreateTestFood()
        Dim lObj As New LunchOrder
        lObj.Quantity = 10
        lObj.StudentID = sObj.StudentID
        lObj.FoodID = fObj.FoodID
        lObj.dt_OrderDate = DateTime.Now
        lObj.Save()

        Dim testTO As LunchOrderTO = lObj.GetTO(GetType(LunchOrderTO))
        Assert.AreEqual(sObj.StudentID.ToString(), testTO.StudentID.ToString())
        Assert.AreEqual(fObj.FoodID.ToString(), testTO.FoodID.ToString())
        Assert.AreEqual(lObj.Quantity, testTO.Quantity)
        Assert.AreEqual(lObj.dt_OrderDate.ToString(), testTO.dt_OrderDate.ToString())
    End Sub


    <Test()> Public Sub testTOsetSubset()
        Dim sObj As Student = New Student
        Dim testTO As New StudentEmailTO
        testTO.Email = "hello@chook.com"
        testTO.Name = "ChickenLicken"
        sObj.AcceptTO(testTO)
        sObj.Save()

        Dim xobj As New Student(sObj.StudentID)
        xobj.Load()
        Assert.AreEqual(xobj.Email, testTO.Email)
        Assert.AreEqual(xobj.Name, testTO.Name)
    End Sub

    <Test()> Public Sub testTOGetSetSubset()
        Dim sObj As Student = Setup.CreateTestStudent()
        sObj.Save()

        Dim testTO As StudentEmailTO = sObj.GetTO(GetType(StudentEmailTO))
        testTO.Email = "hello@chook.com"
        sObj.AcceptTO(testTO)
        sObj.Save()

        Dim xobj As New Student(sObj.StudentID)
        xobj.Load()
        Assert.AreEqual(xobj.Email, testTO.Email)
        Assert.AreEqual(xobj.Name, testTO.Name)
    End Sub


End Class
